<?php
namespace Home\Controller;
use Think\Controller;
class ShopcartController extends CommonController {

	public function _initialize(){
		$this->getshopcart();
		$this->getcolmsg();
	}
	
	//默认显示购物车界面
	public function index(){
		$this->isLogin();
		$this->getshopcart();
		$this->display("shopcart");   
	}
	//显示结算页面
	public  function pay(){
		$this->isLogin();
		$this->getAddress();
		$this->getshopcart();
		$this->display("pay");
	}

	//显示交易成功页面
	public function success(){
		$this->isLogin();
		$userid=$_SESSION['USERID'];
		$Order = M("Orderlist");
		$orderid = I("get.orderid");
		$orderdata = $Order->where("id ={$orderid} ")->find();
		$address = M('Useraddress');
		$addressdata = $address->where("id ={$orderdata['addressid']}")->find();
		$Province = M("Province");
		$City = M("City");
		$District = M('District');
		$province = $Province->where("id ={$addressdata['province']}")->getField("provincename");
		$city = $City->where("id = {$addressdata['city']}")->getField("cityname");
		$district = $District->where("id ={$addressdata['district']}")->getField("districtname");
		
		$this->assign("totalprices",$orderdata['payprices']);
		$this->assign("consignor",$addressdata['consignor']);
		$this->assign("telephone",$addressdata['telephone']);
		$this->assign("province",$province);
		$this->assign("city",$city);
		$this->assign("district",$district);
		$this->assign("detaddress",$addressdata['detaddress']);
		$this->display("success");
	}
	
}